import {fetch} from '../../../utils/axios'

const state = {
  active: [],
  open: [],
  items: []
}

const mutations = {
  changeNginxData (state, res) { // store中的数据只能通过commit mutation来改变
    state.items = res
    console.log(state.items)
  }
}

const actions = {
  fetchNginxForm (context) {
    fetch('http://127.0.0.1:8000/nginx/').then(res => { // 调用接口
      context.commit('changeNginxData', res.results) // 通过接口获取的后台数据保存到store中，等待组件取用
    })
  }
}

export default {
  state,
  mutations,
  actions
}
